#include "actionwalk.h"

ActionWalk::ActionWalk(Lem* lem) : Action(lem)
{
	m_action_name = LEM_ACTION_WALK;

	Animation anim(lem->get_graphics(), STANDARD_LEM_WIDTH, STANDARD_LEM_HEIGHT, STANDARD_WALK_ANIMATION_X,
		STANDARD_WALK_ANIMATION_Y, STANDARD_WALK_ANIMATION_LENGTH, STANDARD_WALK_ANIMATION_TIME);
	m_sprite = new Sprite(anim, true);
}

ActionWalk::~ActionWalk()
{
	delete m_sprite;
}

void ActionWalk::Update(float timing_factor)
{
	// Walk speed is defined here.
	m_lem->set_x(m_lem->x() + 0.1f * timing_factor);

	m_sprite->Update(timing_factor);
}

void ActionWalk::Draw()
{
	// Round correctly.
	m_sprite->set_x(m_lem->x() + 0.5);
	m_sprite->set_y(m_lem->y() + 0.5);

	m_sprite->Draw();
}